/**
 * 水印功能
 * @constructor
 */
import createWaterMaskImg from '@/utils/waterMask'
import './index.less'
import { useEffect, useRef } from 'react'
import moment from 'moment'
import { getRealName } from '@/store/getters'
import { useSelector } from 'react-redux'
const WaterMask = () => {
  const waterMask = useRef<any>(null)
  const realName = useSelector(getRealName)
  useEffect(() => {
    setWaterMask()
  }, [])
  const setWaterMask = () => {
    const loginTime = moment().format('MM-DD HH:mm:ss')
    const src = createWaterMaskImg(realName, loginTime)
    waterMask.current.style.background = `url(${src})`
  }
  return (
    <>
      <div className="water-mask" ref={waterMask}></div>
    </>
  )
}

export default WaterMask
